import 'package:flutter_test/flutter_test.dart';
import 'package:pd_log/src/log_file_info.dart';

void main() {
  group('PDLogFile derived fields', () {
    test('parses year/month/day from POSIX path', () {
      const f = PDLogFile(
        path: '/var/app/pd_log/2025/10/01.log',
        sizeBytes: 123,
        modifiedMs: 0,
      );
      expect(f.year, 2025);
      expect(f.month, 10);
      expect(f.day, 1);
      expect(f.fileName, '2025-10-01.log');
    });

    test('parses year/month/day from Windows path', () {
      final f = PDLogFile(
        path: 'C\\\nProgramData\\pd_log\\2024\\12\\31.log'.replaceAll('\n', ''),
        sizeBytes: 1,
        modifiedMs: 0,
      );
      expect(f.year, 2024);
      expect(f.month, 12);
      expect(f.day, 31);
      expect(f.fileName, '2024-12-31.log');
    });

    test('returns nulls when path format does not match', () {
      const f = PDLogFile(
        path: '/var/app/pd_log/2025/10/01.txt',
        sizeBytes: 1,
        modifiedMs: 0,
      );
      expect(f.year, isNull);
      expect(f.month, isNull);
      expect(f.day, isNull);
      expect(f.fileName, '01.txt');
    });
  });
}
